#include "Subject.h"

Subject::Subject() {};

Subject::~Subject() {};

void Subject::attach(Observer* observer){
	m_observers.push_back(observer);
}

void Subject::detach(Observer* observer){
	int i=0;
	for (i=0; i < (int) m_observers.size(); i++){
		if (m_observers[i] == observer) {
			m_observers.erase(m_observers.begin() + i);
			break;
		}
	}
}

void Subject::notify (const string& command) { 
	for (int i = 0; i < (int) m_observers.size(); i++) 
		(m_observers[i])->update(this, command); 
}


